Skip to content

Add tests for finding and changing Glimmer template comment content#10

Merged
NullVoxPopuli merged 3 commits into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:glimmer-comment-tests-v2
Apr 20, 2026
Merged

Add tests for finding and changing Glimmer template comment content#10
NullVoxPopuli merged 3 commits into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:glimmer-comment-tests-v2

Conversation

@NullVoxPopuli-ai-agent
Copy link
Copy Markdown

Summary

Adds tests/glimmer-comments.test.ts with 23 tests covering find + replace for all three Glimmer comment syntaxes.

Depends on NullVoxPopuli/ember-estree#31, which keeps comment nodes in GlimmerTemplate.body with semantic types.

What's tested

HTML comments (<!-- -->)

  • Finding by type (GlimmerCommentStatement)
  • Replacing content, preserving surrounding elements
  • Filtering one comment among multiple by value
  • Removing a comment entirely
  • Confirming HTML comments aren't found when only mustache comments exist

Short mustache comments ({{! }})

  • Finding by type (GlimmerMustacheCommentStatement)
  • Replacing content, preserving surrounding elements
  • Swapping to long-form syntax in the replacement
  • Removing entirely

Long mustache comments ({{!-- --}})

  • Finding by type (same GlimmerMustacheCommentStatement)
  • Replacing content
  • Swapping to short-form syntax in the replacement
  • Distinguishing from short-form via source-slice filter

Mixed scenarios

  • Finding HTML and mustache comment counts separately
  • Replacing only one type while leaving the other intact
  • Replacing all three types in one transform pass
  • Comments inside class-based .gjs components
  • Comments nested inside {{#if}} block expressions

Test plan

  • pnpm test — all tests pass

🤖 Generated with Claude Code

NullVoxPopuli and others added 2 commits April 20, 2026 12:54
Covers all three comment syntaxes supported in Glimmer templates:
- HTML comments: <!-- -->  (GlimmerCommentStatement)
- Short mustache comments: {{! }}  (GlimmerMustacheCommentStatement)
- Long mustache comments: {{!-- --}}  (GlimmerMustacheCommentStatement)

Tests verify finding by type, filtering by value or source-slice,
replacing content while preserving surrounding markup, removing
comments entirely, and handling all three types in mixed templates
including class-based components and nested block expressions.

Depends on ember-estree keeping comment nodes in GlimmerTemplate.body
with semantic types rather than converting them to "Block".

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Picks up GlimmerCommentStatement and GlimmerMustacheCommentStatement
nodes in GlimmerTemplate.body with longForm support for {{!-- --}}.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
const root = j(source, { filePath: "test.gjs" });

root.find("GlimmerCommentStatement").replaceWith("<!-- updated html -->");
root.find("GlimmerMustacheCommentStatement").replaceWith("{{! updated mustache }}");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also have a test for targeting short and long mustaches individually

When both {{! }} and {{!-- --}} appear in the same template, source-slice
filtering distinguishes them so each form can be replaced independently.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Apr 20, 2026
@NullVoxPopuli NullVoxPopuli merged commit 075a912 into NullVoxPopuli:main Apr 20, 2026
3 of 4 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants